<?php

namespace addons\travel\library\traits\model\order;

use addons\travel\model\Order;
use think\Cache;

trait OrderScope
{
    // 已失效
    public function scopeInvalid($query)
    {
        return $query->where('status', Order::STATUS_INVALID);
    }

    // 已取消
    public function scopeCancel($query)
    {
        return $query->where('status', Order::STATUS_CANCEL);
    }

    // 未支付
    public function scopeNopay($query)
    {
        return $query->where('status', Order::STATUS_NOPAY);
    }

    // 已支付
    public function scopePayed($query)
    {
        return $query->where('status', 'in', [Order::STATUS_PAYED]);
    }

    // 已完成
    public function scopeFinish($query)
    {
        return $query->where('status', Order::STATUS_FINISH);
    }
    // 可以删除的订单
    public function scopeCanDelete($query)
    {
        return $query->where('status', 'in', [
            Order::STATUS_CANCEL, 
            Order::STATUS_INVALID,
            Order::STATUS_FINISH
        ]);
    }
    // 已完成
    public function scopeFinishservice($query)
    {
        return $query->where('is_finish_service',1);
    }
}
